
#include <iostream>

#include <StackInfo.hpp>

class Test {
public:
    int p1 = 1;
    bool p2 = false;
    std::string p3 = "p33333333";

    void testWithStack(StackInfo &stack) {
        int v1 = 0;
        std::string v2;
        Test v3;
        Test *v4 = nullptr;

        // push 进入参数
        v4 = stack.pop<Test *>();
        v3 = stack.pop<Test>();
        v2 = stack.pop<std::string>();
        v1 = stack.pop<int>();

        std::cout << "testWithStack: "
                  << v1 << " "
                  << v2 << " "
                  << v3.p3 << " "
                  << v4->p3 << std::endl;

        stack.push(1);
    }
};

void test2() {
    Test t1;

    // 构造参数栈
    StackInfo stack = StackInfo::makeStackInfo<int, int, std::string, Test, Test *>(); // 返回值 int, 参数为 int,std::string,Test,Test*
    // push 进入参数
    stack.push(111);
    stack.push<std::string>("asdfasdfasdf");
    Test t2;
    t2.p3 = "t2teststring";
    stack.push(t2);
    stack.push(&t1);

    // 调用函数
    t1.testWithStack(stack);

    // 取出返回值
    std::cout << "testWithStack ret " << stack.pop<int>() << std::endl;
}

int main() {
    test2();
    return 0;
}
